<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${packageName}.mapper.${table.className}Mapper" >
	<#--<resultMap id="${table.className?uncap_first}" type="${packageName}.entity.${table.className}Entity" >
		<#list table.columns as column>
		<#if column.primaryKey>
		    <id column="${column.fieldDbName}" property="${column.fieldName}" jdbcType="${column.fieldDBType}" />
		<#else>
		    <result column="${column.fieldDbName}" property="${column.fieldName}" jdbcType="${column.fieldDBType}" />
		</#if>
	   </#list>
	</resultMap>-->


    <sql id="Base_Column_List" >
        ${table.selectKeys}
    </sql>

    <sql id="Example_Where_Clause">
        <where>
            1=1
        <#list table.columns as column>
            <if test="${column.fieldName} != null" >
                and a.${column.fieldDbName} = ${r"#{"}${column.fieldName}${r"}"},
            </if>
        </#list>
        </where>
    </sql>

    <select id="get${table.className?cap_first}" parameterType="java.util.HashMap" resultType="java.util.HashMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM ${table.tableName} a
        <include refid="Example_Where_Clause" />
    </select>
  <#--
  <insert id="insert" parameterType="${packageName}.entity.${table.className}Entity">
	INSERT INTO ${table.tableName}
    <trim prefix="(" suffix=")" suffixOverrides="," >
       <#list table.columns as po>
      	  <if test="${po.fieldName} != null" >
	        ${po.fieldDbName},
	      </if>
	   </#list>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
    	<#list table.columns as po>
	      <if test="${po.fieldName} != null" >
	       ${r"#{"}${po.fieldName}${r"}"},
	      </if>
	   </#list>
    </trim>
    <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="zid" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    </insert>
    
    <update id="update" parameterType="${packageName}.entity.${table.className}Entity" >
	    UPDATE ${table.tableName}
	    <set >
	    	<#list table.columns as po>
		    <if test="${po.fieldName} != null" >
	        ${po.fieldDbName} = ${r"#{"}${po.fieldName}${r"}"},
	        </if>
	        </#list>
	    </set>
	    where zid = ${r"#{zid}"}
    </update>
    <update id="updateByExample" parameterType="${packageName}.entity.${table.className}Entity" >
	    UPDATE ${table.tableName}
	    <set >
	    	<#list table.columns as po>
		    <if test="${r"#{entity."}${po.fieldName}${r"}"} != null" >
	        ${po.fieldDbName} = ${r"#{entity."}${po.fieldName}${r"}"},
	        </if>
	        </#list>
	    </set>
	    <if test="_parameter != null" >
	      <include refid="Update_By_Example_Where_Clause" />
	    </if>
    </update>
    
    <delete id="deleteById" parameterType="java.lang.String" >
	    DELETE FROM ${table.tableName}
	    WHERE zid = ${r"#{zid}"}
	</delete>
	
	<delete id="deleteByExample" parameterType="criteria" >
	    DELETE FROM ${table.tableName}
	    <if test="_parameter != null" >
	      <include refid="Example_Where_Clause" />
	    </if>
	 </delete>
	 
	 <select id="getEntityById" resultMap="${table.className?uncap_first}" parameterType="java.lang.String" >
	    SELECT 
	    <include refid="Base_Column_List" />
	    FROM ${table.tableName} a
	    WHERE a.zid = ${r"#{zid}"}
	  </select>
	  
	  <select id="getEntityMapById" resultType="hashMap" parameterType="java.lang.String" >
	    SELECT 
	    <include refid="Base_Column_List" />
	    FROM ${table.tableName} a
	    WHERE a.zid = ${r"#{zid}"}
	  </select>
	  
	  
	  <select id="selectByExample" resultMap="${table.className?uncap_first}" parameterType="criteria" >
	    SELECT
	    <if test="distinct" >
	      distinct
	    </if>
	    <include refid="Base_Column_List" />
	     FROM ${table.tableName} a
	    <if test="_parameter != null" >
	      <include refid="Example_Where_Clause" />
	    </if>
	    <if test="orderByClause != null" >
	      order by ${r"${orderByClause}"}
	    </if>
	    <if test="limitStart >=0 and pageSize>0 " >
	      limit ${r"#{limitStart}"} , ${r"#{pageSize}"}
	    </if>
	  </select>
	  
	  <select id="selectPageByExample" resultMap="${table.className?uncap_first}" parameterType="criteria" >
	     SELECT
	    <if test="distinct" >
	      distinct
	    </if>
	    <include refid="Base_Column_List" />
	     FROM ${table.tableName} a
	    <if test="_parameter != null" >
	      <include refid="Example_Where_Clause" />
	    </if>
	    <if test="orderByClause != null" >
	      order by ${r"${orderByClause}"}
	    </if>
	    <if test="limitStart >=0 and pageSize>0 " >
	      limit ${r"#{limitStart}"} , ${r"#{pageSize}"}
	    </if>
	  </select>
	  
	  <select id="selectMapByExample" resultType="hashMap" parameterType="criteria" >
	    SELECT
	    <if test="distinct" >
	      distinct
	    </if>
	    <include refid="Base_Column_List" />
	     FROM ${table.tableName} a
	    <if test="_parameter != null" >
	      <include refid="Example_Where_Clause" />
	    </if>
	    <if test="orderByClause != null" >
	      order by ${r"${orderByClause}"}
	    </if>
	    <if test="limitStart >=0 and pageSize>0 " >
	      limit ${r"#{limitStart}"} , ${r"#{pageSize}"}
	    </if>
	  </select>
	  
	  <select id="countByExample" resultType="java.lang.Long" parameterType="criteria" >
	    SELECT count(1) FROM ${table.tableName} a
	    <if test="_parameter != null" >
	      <include refid="Example_Where_Clause" />
	    </if>
	  </select>
	  -->
</mapper>
